﻿using System;
using System.Collections.Generic;

namespace COC.Tool{
    public class GenerateUniqueNumber
    {
        private  static int NextCommandId=0;
        private int nextId;
        static GenerateUniqueNumber gUN=new GenerateUniqueNumber();
        private object obj=new object();
        public static int New()
        {
            int value = NextCommandId++;
            return value;
        }

        public static GenerateUniqueNumber getInstance()
        {
            return gUN;
        }
        public int getNewNumber()
        {
            lock (obj)
            {
                nextId++;
            }
            return nextId;
        }
    }
}
